package 统计算法.寻找数组中心下标;

import java.util.Arrays;

public class xzszzxxb {
    public static void main(String[] args) {

    }
    public static int pivotIndex(int[] nums) {
        int total = Arrays.stream(nums).sum();
        int sum = 0;
        for (int i = 0; i < nums.length; i++) {
            if (2*sum+nums[i] == total){
                return i;
            }
            sum += nums[i];
        }
        return -1;
    }
}
